package com.MedDroid.task;

import android.os.AsyncTask;
import com.MedDroid.activity.MedicalPageActivity;
import com.MedDroid.control.AuthenticationControl;
import com.MedDroid.control.DatabaseControl;

import java.lang.ref.WeakReference;
import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: Romen
 * Date: 03/12/13
 * Time: 1:21 AM
 * Description:
 */
public class LoadMedicalPageTask extends AsyncTask<Integer, Void, ArrayList<String>>
{
	AuthenticationControl AuthenticationC;
	DatabaseControl DatabaseC;
	WeakReference<MedicalPageActivity> MedicalPage;

	public LoadMedicalPageTask(AuthenticationControl Auth, DatabaseControl Data, MedicalPageActivity activity)
	{
		AuthenticationC = Auth;
		DatabaseC = Data;
		MedicalPage = new WeakReference<MedicalPageActivity>(activity);
	}

	@Override
	protected ArrayList<String> doInBackground(Integer... UserID)
	{
		return DatabaseC.getUser(UserID[0]).getComments();
	}

	@Override
	protected void onPostExecute(ArrayList<String> List)
	{
		MedicalPageActivity Page = MedicalPage.get();
		Page.CommentsList = List;
		Page.makeList();
	}
}
